﻿using Abp.vNext.WT.Domain.Issues;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.AuditLogging.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.Modeling;

namespace Abp.vNext.WT.EntityFrameworkCore.EntityFrameworkCore
{
    [ConnectionStringName("Default")]
    public class WebApiDbContext : AbpDbContext<WebApiDbContext>
    {
        public WebApiDbContext(DbContextOptions<WebApiDbContext> options) : base(options)
        {
        }

        // 添加表（聚合根）
        public DbSet<Issue> Issues { get; set; }

        // 修改表配置
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.ConfigureAuditLogging();
            // 配置Issue表
            IssueConfig(modelBuilder);

        }

        private void IssueConfig(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Issue>(b =>
            {
                //b.ToTable("Issue");
                b.ConfigureByConvention(); //auto configure for the base class props
            });
        }

    }
}
